<!--
    @author: wzc
    @description:首页
-->
<template>
	<view class="container">
		<u-navbar leftIcon="" title="首页" :titleStyle="{fontSize: '36rpx'}" placeholder />

		<view
			style="width: 100%;height: 90rpx;line-height: 90rpx;background-color: #007aff;margin: 20rpx 0;color: #FFFFFF;text-align: center"
			@click="onPlaySoundClick">播放</view>

		<view style="height: 100vh;background-color: #f0ad4e">
			<view v-for="(item,index) in 200">
				版本号：{{ index }} {{ $store.state.version }}
			</view>
		</view>

		<c-loading></c-loading>
	</view>
</template>

<script>
	import * as JOSN from "postcss";
	import {
		isAppLiveRequest
	} from "../../net/Api.js";

	export default {
		name: "home",
		computed: {},
		watch: {},
		data() {
			return {
				name: "wzc",
				age: "18",
				audioContext: null,
				timer: null,
			};
		},
		onLoad(options) {


		},
		mounted() {
			// #ifdef APP-PLUS
			// const app_active = uni.requireNativePlugin("app_active");
			// app_active.getTestData()
			// console.log("app_active getTestData = ", app_active.getTestData())
			// #endif

			// if (this.timer == null) {
			// 	this.timer = setInterval(() => {
			// 		this.isAlive()
			// 	}, 10000)
			// }
		},
		methods: {
			isAlive() {
				let params = {
					id: 20241228
				}
				isAppLiveRequest(params).then((res) => {
					console.log("isAppLiveRequest res = ", res);
				}).catch((err) => {

				})
			},

			getUserInfo() {
				console.log("调用方法")
				return "调用方法"
			},
			onPlaySoundClick() {
				console.log("播放");

				this.audioContext.play();
				// #ifdef APP-PLUS
				if (plus.os.name == 'Android') { // 确保只在Android上运行
					plus.push.createMessage('这是消息内容', 'msgId', {
						title: '新的任务',
						extra: {
							customKey: 'customValue'
						}
					});
					
					plus.push.addEventListener('click', function(msg) {
					    console.log('用户点击了通知：', msg);
					    // 用户点击通知后执行的代码
					    uni.navigateTo({
					        url: '/pages/netWork/netWork'
					    });
						// plus.push.clear();
					}, false);
				}
				// #endif
			},
			onSubTitleClick() {
				console.log("onSubTitleClick")
			},
		},
	};
</script>

<style scoped lang="scss">
	.container {
		width: 100%;
		background-color: #FFFFFF;
		display: flex;
		flex-direction: column;
	}
</style>